package com.foreknow.elmboot.service.impl;

import com.foreknow.elmboot.mapper.DeliveryAddressMapper;
import com.foreknow.elmboot.po.DeliveryAddress;
import com.foreknow.elmboot.service.DeliveryAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class DeliveryAddressServiceImpl implements DeliveryAddressService {
    @Autowired
    private DeliveryAddressMapper deliveryAddressMapper;

    @Override
    public List<DeliveryAddress> listDeliveryAddressByUserId(String userId) {
        List<DeliveryAddress> list=null;
        try {
            list=deliveryAddressMapper.listDeliveryAddressByUserId(userId);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return list;
    }

    @Override
    public DeliveryAddress getDeliveryAddressById(Integer daId) {
        DeliveryAddress deliveryAddress=null;
        try {
            deliveryAddress=deliveryAddressMapper.getDeliveryAddressById(daId);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return deliveryAddress;
    }

    @Override
    public int saveDeliveryAddress(DeliveryAddress deliveryAddress) {
        int result=0;
        try {
            result=deliveryAddressMapper.saveDeliveryAddress(deliveryAddress);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return result;
    }

    @Override
    public int updateDeliveryAddress(DeliveryAddress deliveryAddress) {
        int result=0;
        try {
            result=deliveryAddressMapper.updateDeliveryAddress(deliveryAddress);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return result;
    }

    @Override
    public int removeDeliveryAddress(Integer daId) {
        int result=0;
        try {
            result=deliveryAddressMapper.removeDeliveryAddress(daId);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return result;
    }
}
